-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE ember-application-engines] Initial extraction of engines from applications #12685
Conversation
@@ -83,24 +79,20 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { | |||
rootElement: null, | |||
|
|||
init() { | |||
this._super(...arguments); | |||
let application = get(this, 'application'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interacting with this
before super()
in a constructor is not compatible with ES6 classes, fwiw. If this can be differently factored, I think that would be ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, @mixonic. I was able to refactor it such that the engine instance is aware that application
might be set instead of base
(i.e. if base
is not set, then application
is checked). if others agree that base
is general enough to specify the base class for both engine and application instances, we can consider deprecating the application
property at some point.
Thanks for your work on this @dgeb Cheers |
@uses ContainerProxyMixin | ||
*/ | ||
|
||
let EngineInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
@stefanpenner thanks for the review. I've just revised as per your suggestions, with the two exceptions:
@rwjblue thoughts? |
Ember.Engine = Engine; | ||
|
||
// Expose EngineInstance for easy overriding. Reanalyze whether to | ||
// continue exposing it after feature flag is removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we should likely remove it. ApplicationInstance
is not exposed at all, so we should follow that (or expose it as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated exposing ApplicationInstance
here as well - maybe we should for consistency and then remove both after the feature flag is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care which way we go, but we need to be consistent. Either both are exposed, or neither are...
The doc strings for |
return properties; | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a small description here? This is the header page that shows up for the class in our API docs...
@rwjblue Good catch. I just updated |
Confirm. |
…n to Engine. Initializers and instance initializers are a common concern for applications and engines.
…ncerns for engines. Provide a spare base implementation of `buildRegistry` for `Engine`, which is extended by `Application`. Also, allow for a custom `Resolver` property on `Engine` (and by extension, `Application`).
…tialization for engine instances. Move registry and container creation from `ApplicationInstance` to `EngineInstance`.
Only expose `Ember.Engine` when feature flag is enabled.
Replicate appropriate tests from applications. We don’t want to yet move tests while engines are feature flagged and in flux.
Replicate appropriate tests from application instances. We don’t want to yet move tests while engines are feature flagged and in flux.
…mber.ApplicationInstance. Expose Ember.EngineInstance and Ember.ApplicationInstance for easy overriding. Need to reanalyze whether to continue exposing them after feature flag is removed.
@rwjblue I've added a brief description for Thanks for the review - let me know if I've overlooked any other suggestions. |
[FEATURE ember-application-engines] Initial extraction of engines from applications
This initial PR for engines follows the strategy proposed in the Engines RFC.
It introduces a base class,
Engine
, which is wholly extracted from (and then extended by)Application
. Similarly,EngineInstance
has been wholly extracted from (and then extended by)ApplicationInstance
.The
Engine
base class is now responsible for maintaining a registry and initializers.The
EngineInstance
base class is now responsible for maintaining an instance-level registry and container.Ember.Engine
is only exposed when the newember-application-engines
feature flag is enabled.The APIs and behavior of
Application
andApplicationInstance
remain identical, as do tests and documentation.Some tests of extracted behavior were duplicated for engines, but the original tests for applications were kept in place. Any test duplication should be revisited before the feature flag is enabled.
The primary purpose of this PR is to allow for further experimentation with engines in an addon. It will also allow behavior to be folded into ember core gradually as experimentation proceeds.